package p270jp.pxv.android.view;

import android.content.Context;
import android.os.Build;
import android.text.Html;
import android.text.Spanned;
import android.text.method.LinkMovementMethod;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Locale;
import p014ae.View$OnClickListenerC0054c;
import p270jp.pxv.android.R;
import p270jp.pxv.android.legacy.constant.ContentType;
import p270jp.pxv.android.legacy.model.PixivIllust;
import p270jp.pxv.android.legacy.model.PixivNovel;
import p270jp.pxv.android.legacy.model.PixivTag;
import p270jp.pxv.android.legacy.model.PixivWork;
import p314lg.WorkCaptionDetailItemBinding;
import p325m0.MutabilityOwnership;

/* compiled from: DetailCaptionAndTagsView.kt */
/* renamed from: jp.pxv.android.view.DetailCaptionAndTagsView */
/* loaded from: classes2.dex */
public final class DetailCaptionAndTagsView extends RelativeLayout {

    /* renamed from: c */
    public static final /* synthetic */ int f19480c;

    /* renamed from: a */
    public final WorkCaptionDetailItemBinding f19481a;

    /* renamed from: b */
    public PixivWork f19482b;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public DetailCaptionAndTagsView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        MutabilityOwnership.m3745m(context, "context");
        MutabilityOwnership.m3745m(attributeSet, "attrs");
        ViewDataBinding c = DataBindingUtil.m11370c(LayoutInflater.from(getContext()), R.layout.work_caption_detail_item, this, true);
        MutabilityOwnership.m3746l(c, "inflate(\n        LayoutI…il_item, this, true\n    )");
        WorkCaptionDetailItemBinding ncVar = (WorkCaptionDetailItemBinding) c;
        this.f19481a = ncVar;
        ncVar.f22022v.setOnClickListener(new View$OnClickListenerC0054c(this, 27));
    }

    /* renamed from: a */
    public final void m4504a(String str) {
        Spanned spanned;
        if (str.length() > 0) {
            this.f19481a.f22017q.setMovementMethod(LinkMovementMethod.getInstance());
            SelectableTextView selectableTextView = this.f19481a.f22017q;
            if (Build.VERSION.SDK_INT >= 24) {
                spanned = Html.fromHtml(str, 0);
            } else {
                spanned = Html.fromHtml(str);
            }
            selectableTextView.setText(spanned);
        }
    }

    /* renamed from: b */
    public final void m4503b(PixivWork pixivWork) {
        this.f19481a.f22023w.setText(String.valueOf(pixivWork.totalView));
        this.f19481a.f22022v.setText(String.valueOf(pixivWork.totalBookmarks));
        if (pixivWork.totalBookmarks == 0) {
            TextView textView = this.f19481a.f22022v;
            Context context = getContext();
            MutabilityOwnership.m3746l(context, "context");
            TypedValue typedValue = new TypedValue();
            if (context.getTheme().resolveAttribute(R.attr.colorCharcoalText3, typedValue, true)) {
                textView.setTextColor(typedValue.data);
                return;
            }
            throw new IllegalStateException("Charcoal Theme, もしくは Charcoal Bridge Theme を利用してください");
        }
        TextView textView2 = this.f19481a.f22022v;
        Context context2 = getContext();
        MutabilityOwnership.m3746l(context2, "context");
        TypedValue typedValue2 = new TypedValue();
        if (context2.getTheme().resolveAttribute(R.attr.colorCharcoalBrand, typedValue2, true)) {
            textView2.setTextColor(typedValue2.data);
            return;
        }
        throw new IllegalStateException("Charcoal Theme, もしくは Charcoal Bridge Theme を利用してください");
    }

    public final void setIllust(PixivIllust pixivIllust) {
        MutabilityOwnership.m3745m(pixivIllust, "illust");
        this.f19482b = pixivIllust;
        this.f19481a.f22018r.setText(new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.US).format(pixivIllust.createDate));
        m4503b(pixivIllust);
        ContentType contentType = ContentType.ILLUST;
        List<PixivTag> list = pixivIllust.tags;
        MutabilityOwnership.m3746l(list, "illust.tags");
        this.f19481a.f22020t.m4619c(contentType, list, null);
        String str = pixivIllust.caption;
        MutabilityOwnership.m3746l(str, "illust.caption");
        m4504a(str);
    }

    public final void setNovel(PixivNovel pixivNovel) {
        MutabilityOwnership.m3745m(pixivNovel, "novel");
        this.f19482b = pixivNovel;
        this.f19481a.f22018r.setText(new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.US).format(pixivNovel.createDate));
        m4503b(pixivNovel);
        ContentType contentType = ContentType.NOVEL;
        List<PixivTag> list = pixivNovel.tags;
        MutabilityOwnership.m3746l(list, "novel.tags");
        this.f19481a.f22020t.m4619c(contentType, list, null);
        String str = pixivNovel.caption;
        MutabilityOwnership.m3746l(str, "novel.caption");
        m4504a(str);
    }
}
